package com.bachelor.community.controller;

import com.bachelor.community.annotation.UnInterception;
import com.bachelor.community.service.intf.AnswerService;
import com.bachelor.community.utils.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/search")
public class SearchController {
    @Resource
    private AnswerService answerService;

    @GetMapping
    @UnInterception
    public Result listAnswersByKeyword(@RequestParam("offset") int currentPage,
                                       @RequestParam("limit") int pageSize,
                                       @RequestParam(value = "order", defaultValue = "latest") String orderColumn,
                                       @RequestParam(value = "keyword", required = false) String keyword) {
        return Result.succeed("200", answerService.listAnswersByKeyword(currentPage, pageSize, orderColumn, keyword));
    }
}
